<?php

/** libraries
 * http://docs.joomla.org/JToolBarHelper
 */

// No direct access to this file
defined('_JEXEC') or die('Restricted access');

// import Joomla view library
jimport('joomla.application.component.view');

class bgViewbg extends JView
{
	// Overwriting JView display method
	function display($tpl = null) 
	{
	   
        $model = $this->getModel();
        $aut = new bgAuthorize();
        
       
        switch(JRequest::getVar('task')){
            case 'error':
                $this->data = JRequest::getVar('jform');
                $this->id_DOWI = $this->data['DOWI_CODE'];
                //Get List Category download
                $this->list_cadm = $model->getAllCadm();
                
                
                $this->setLayout('a01610');
                JToolBarHelper::save('save','登録');
               	JToolBarHelper::cancel('cancel', 'キャンセル');
                JToolBarHelper::title( 'ダウンロード集作成 ','download.png' );
                
                break;
                
            case 'popup_cadm':
                
                $this->list_cadm =& $model->getAllCadmPopup();
                               
                $this->setLayout('popup_cadm');
            break;
                
            case 'add':
                //Create ID for COCLI
                $id = $model->getMaxDOWI_CODE();
                $this->id_DOWI = $id + 1;
                //Get List Category download
                $this->list_cadm = $model->getAllCadm();
                
                $this->setLayout('a01610');
                
            	JToolBarHelper::title( 'ダウンロード集作成 ', 'download.png' );
                JToolBarHelper::save('save','登録');
            	JToolBarHelper::cancel('cancel', 'キャンセル');
                
            	break;
            	    
            default :
                //search
                $this->list['filter_search'] = &JRequest::getVar('filter_search');
                
                // Get data from the model
                $this->rows =& $model->getAllDownload($this->list);  
                $this->pagination =& $this->get('Pagination');
                
            	JToolBarHelper::title( 'ダウンロード集管理', 'download.png' );
                
                if($aut->checkAdd()){
                    JToolBarHelper::addNew('add','作成');
                }
                
                if($aut->checkDelete()){
            	    JToolBarHelper::deleteList('', 'remove','削除');
                }
                
                $this->setLayout('a01600');
    	}
        
    	parent::display();
	}
}




